package o;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import com.huawei.appgallery.forum.user.api.OpenLoginCheckerAction;
import com.huawei.appgallery.forum.user.api.OpenLoginCheckerAction.d;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.widget.dialog.dialogactivity.DialogActivity.a;
import com.huawei.gamebox.plugin.gameservice.view.TransferActivity;

public class cbl extends cfh {
    private boolean ˊ = false;
    private boolean ˎ;
    private Handler ˏ = new Handler(Looper.getMainLooper());

    public cbl(Context context, boolean z) {
        this.context = context;
        this.ˎ = z;
    }

    public void doCheck() {
        bqx.ˏ("LoginChecker", "start check if the user is login");
        if (UserSession.getInstance().isLoginSuccessful()) {
            checkSuccess();
        } else {
            ˎ();
        }
    }

    public String getName() {
        return "LoginChecker";
    }

    private void ˎ() {
        if (this.ˎ) {
            OpenLoginCheckerAction.setOpenCallBack(new d(this) {
                final /* synthetic */ cbl ˊ;

                {
                    this.ˊ = r1;
                }

                public void ˏ(AlertDialog alertDialog, a aVar, int i, Context context) {
                    this.ˊ.ˊ = true;
                    if (-1 == i) {
                        this.ˊ.ˏ(context);
                    } else {
                        this.ˊ.checkFailed();
                    }
                }

                public void ॱ(DialogInterface dialogInterface) {
                    if (!this.ˊ.ˊ) {
                        this.ˊ.checkFailed();
                    }
                }
            });
            ((faj) cdb.ॱ(faj.class)).ˊ(this.context, TransferActivity.class, new Intent(OpenLoginCheckerAction.ACTION));
            return;
        }
        final cbm o_cbm = new cbm(this.context);
        o_cbm.ˏ(new ckh.a(this) {
            final /* synthetic */ cbl ˊ;

            public void ˏ(AlertDialog alertDialog, a aVar, int i) {
                this.ˊ.ˊ = true;
                if (-1 == i) {
                    this.ˊ.ˏ(this.ˊ.context);
                } else {
                    this.ˊ.checkFailed();
                }
                o_cbm.ॱ();
            }
        });
        o_cbm.ˊ(new OnDismissListener(this) {
            final /* synthetic */ cbl ॱ;

            {
                this.ॱ = r1;
            }

            public void onDismiss(DialogInterface dialogInterface) {
                if (!this.ॱ.ˊ) {
                    this.ॱ.checkFailed();
                }
            }
        });
        o_cbm.ˏ();
    }

    private void ˏ(Context context) {
        eoj.ˋ().ˎ("LoginChecker", new AccountBussinessListener(this) {
            final /* synthetic */ cbl ˋ;

            {
                this.ˋ = r1;
            }

            public void onAccountBusinessResult(final ccp o_ccp) {
                eoj.ˋ().ˊ("LoginChecker");
                this.ˋ.ˏ.post(new Runnable(this) {
                    final /* synthetic */ AnonymousClass1 ˏ;

                    public void run() {
                        if (102 == o_ccp.ˎ) {
                            this.ˏ.ˋ.checkSuccess();
                        } else {
                            this.ˏ.ˋ.checkFailed();
                        }
                    }
                });
            }
        });
        eod.ˊ(context, null, false, true, true);
    }
}
